package com.itheima.mapper;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SetmealCheckGroupMapper {

    /**
     * 根据套餐id查询检查组id集合
     * @param setmealId
     * @return
     */
    @Select("select checkgroup_id from t_setmeal_checkgroup where setmeal_id = #{setmealId}")
    List<Integer> findCheckGroupIdsBySetmealID(Integer setmealId);

    /**
     * 批量插入套餐和检查组关系
     * @param setmealId
     * @param checkgroupIds
     */
    void insertBatch(Integer setmealId, List<Integer> checkgroupIds);

    /**
     * 根据套餐id删除套餐和检查组关系
     * @param setmealId
     */
    @Delete("delete from t_setmeal_checkgroup where setmeal_id = #{setmealId}")
    void deleteBySetmealId(Integer setmealId);

    /**
     * 根据检查组id查询检查组被关联的套餐数量
     * @param checkgroupId
     * @return
     */
    @Select("select count(*) from t_setmeal_checkgroup where checkgroup_id = #{checkgroupId}")
    Integer countByCheckGroupId(Integer checkgroupId);
}
